//
//  AILDSummary.m
//  carcareIOS
//
//  Created by ileo on 15/6/16.
//  Copyright (c) 2015年 baozun. All rights reserved.
//

#import "AILDSummary.h"

@implementation AILDSummary

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.dbSummary = [[DBSummary alloc] init];
        
        [self updateLocalData];
    }
    return self;
}

-(void)updateLocalData{
    self.requestedMonth = NO;
    self.requestedYear = NO;
    [self.dbSummary reCreateTable];
}

-(BOOL)needAutoSaveUserDefaultForProperty:(Property *)property{
    if ([property.name isEqualToString:@"dbSummary"]) {
        return NO;
    }
    return YES;
}

-(BOOL)requestedWithType:(Summary_Type)type{
    switch (type) {
        case Summary_Year:
            return self.requestedYear;
            break;
        case Summary_Month:
            return self.requestedMonth;
            break;
        case Summary_Week:
            return self.requestedMonth;
            break;
        default:
            break;
    }
    return NO;
}

-(void)setRequestedOKWithType:(Summary_Type)type{
    switch (type) {
        case Summary_Year:
            self.requestedYear = YES;
            break;
        case Summary_Month:
        case Summary_Week:
            self.requestedMonth = YES;
            break;
            
        default:
            break;
    }
}

@end



@implementation TriggerSummary

-(void)triggerByAccountUpdate{
    [[[AILDSummary alloc] init] updateLocalData];
}

-(void)triggerByDateUpdate{
    [[[AILDSummary alloc] init] updateLocalData];
}

-(void)triggerByVersionUpdate{
    [[[AILDSummary alloc] init] updateLocalData];
}

@end